package com.zjq.designpatterns.struct.flyweight.code;/*
 * 版权信息: 北京千⾥马网信科技有限公司</br>
 * Copyright ©2008-2018. All rights reserved. 京ICP备16007318号
 */

import java.util.HashMap;
import java.util.Map;

/**
 * @author jessie
 * @version 1.0
 * @date 2021/1/23
 */
public class EmployeeFactory {
    //static final 会是大写的
    //这个map就是对象池
    private static final Map<String, Employee> EMPLOYEE_MAP = new HashMap<>();
    public static Employee getManager(String department){
        Manager manager = (Manager) EMPLOYEE_MAP.get(department);
        if(manager== null){
            manager = new Manager(department);
            System.out.print("创建部门经理:"+department);
            String reportContent = department+"部门汇报：此次报告的主要内容是......";
            manager.setReportContent(reportContent);
            System.out.println(" 创建报告:"+department);
            EMPLOYEE_MAP.put(department, manager);
        }
        return manager;
    }
}
